<%@ page import="model.subjects.Enterprise, database.dao.EnterpriseDAO, model.Attribute, java.util.LinkedList, model.Address, java.sql.Date" language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>
<jsp:useBean id="subject" scope="request" type="model.subjects.Enterprise"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ettevõtte andmete muutmine</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="static/js/javascript.js"></script>

</head>

<a href='http://imbi.ld.ttu.ee/tomcat_webapp_logs/t103755_subjekt/log.txt'>loggid</a> ||<a href="LoginServlet?action=logout">Logi välja</a> 


<ul>
<a href='LoginServlet?action=login'>Otsing</a> || 
<a href='s?action=display_add_person'>Lisa Isikuid</a> || 
<a href='s?action=display_add_enterprise'>Lisa ettevõtteid</a> || 

</ul>



<body><h1>Ettevõtte andmete muutmine</h1>

<a href="#" id="display_contacts" >Kontaktid</a>
<a href="#" id="display_addresses" >Aadressid</a>
<a href="#" id="display_modify_person" >Ettevõtte Andmed</a>

<br>




<jsp:include page="Addresses.jsp"/>
<jsp:include page="Contacts.jsp"/><br/><br/>


<div id="show_modify_enterprise">

<h1>Ettevõtte Andmed</h1>
<table>

<a href="s?action=display_add_employees&enterprise_id=<%out.println(subject.getId());%>">Lisa töötajaid</a><br/>
<a href="s?action=display_give_roles&enterprise_id=<%out.println(subject.getId());%>">Anna Rolle</a>




<!--  <button>Lisa töötajaid</button>--> <!-- Või ettevõttega seotud isikuid vms. Seal peab saama ka rolli valida. Ja see nupp vms vb hoopis üles serva -->

<form action='s?action=modify_enterprise' method='post' >

<!--  Üldised atribuudid -->
<input name="id" style="display:none" value="<%out.println(subject.getId());%>">
<tr><td>Nimi </td><td><input name="name" type="text" value="<%out.println(subject.getName());%>"><br/></tr></td>
<tr><td>Täisnimi </td><td><input name="full_name" type="text" value="<%out.println(subject.getFullname());%>"><br/></tr></td>
<br/>
<%
//Ettevõtte atribuudid

LinkedList<Attribute> attributes = subject.getAttributes();
for(Attribute a: attributes){
	int dataType = a.getDataType();
	out.println("<tr><td><label>"+a.getName()+ " </label></td><td><input name=\"" + a.getName() + "\" type=\"");
	if(dataType == 1){
		out.println("text\" value=\""+a.getValue()+"\" ");
	}else if(dataType == 2){
		out.println("number\" value=\""+a.getValue()+"\" ");
	}else{
		out.println("date\" value=\""+a.getValue()+"\" ");
	}
	//out.println("\" ");
	if(a.isRequired()){
		out.println("required");
	}
	out.println(" ><br/></tr></td>"); //inputi lõpp
	
}
%>
<br/>
<tr><td>Kliendiks </td><td><input name="make_customer" type="checkbox"></tr></td>
<br/>
<tr><td> </td><td><input type="submit" value="Muuda"></tr></td></table>

</form>
</div>
</body>
</html>